package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AgentUserMessage;
import com.vf.admin.miaodong.entity.AppAuth;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Repository
public class AgentUserMessageDao extends BaseDao<AgentUserMessage> {

    public List<AgentUserMessage> page(Map<String, Object> paraMap, SplitPageBean splitPage) {
        ArrayList<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("select * from agent_user_message where 1=1");
        if(paraMap.containsKey("userId")) {
            sbStr.append(" and userId=?");
            paramList.add(paraMap.get("userId"));
        }
        if(paraMap.containsKey("userName")) {
            sbStr.append(" and userName=?");
            paramList.add(paraMap.get("userName"));
        }
        sbStr.append(" order by createTime desc");
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, AgentUserMessage.class, splitPage);
    }

    public void readMessage(String ids) {
        ArrayList<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("update agent_user_message set isRead=1 where id in ("+ ids +")");

        String sql = sbStr.toString();
        this.update(sql, paramList);
    }

}
